import datetime

s = input()
year = int(s[:4])
month = int(s[4:6])
day = int(s[6:])
dt = datetime.date(year, month, day)
flag = 1
while True:
    dt += datetime.timedelta(days=1)
    s = "{}{:0>2d}{:0>2d}".format(dt.year, dt.month, dt.day)
    if s[:] == s[::-1]:
        if flag:
            print(s)
            flag = False
        if s[0] == s[2] == s[5] == s[7] and s[1] == s[3] == s[4] == s[6]:
            print(s)
            break
